package main

func main() {

}

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func isSameTreeError(p *TreeNode, q *TreeNode) bool {
	if (p == nil && q == nil) || ((p != nil && q != nil) && p.Val == q.Val) { //如果这里是nil就不应该再比较它们的子树
		return isSameTreeError(p.Left, q.Left) && isSameTreeError(p.Right, q.Right)
	} else {
		return false
	}
}

func isSameTreeRight(p *TreeNode, q *TreeNode) bool {
	if p == nil && q == nil {
		return true
	} else if (p != nil && q != nil) && p.Val == q.Val {
		return isSameTreeRight(p.Left, q.Left) && isSameTreeRight(p.Right, q.Right)
	} else {
		return false
	}
}
